home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CDsupport / IDer / Routines / ProcessOffset.s < prev    next >
Text File  |  1997-02-18  |  3KB  |  102 lines

  1. ProcessOffset:    Move.L    _Offset(PC),A0        ;was the annoying option included?
  2.     Cmp.L    #0,A0
  3.     Beq    .NoOffset
  4.  
  5.     Lea    WorkData,A1
  6.     Moveq    #0,D0
  7. .OffsetCopy    Move.B    (A0)+,D0        ;we need to get all the numbers before the comma
  8.     Beq    .BadOffset        ;and put them elsewhere where we can work with them
  9.     Move.B    D0,(A1)+
  10.     Cmp.B    #',',D0        ;the comma is the seperator
  11.     Bne.S    .OffsetCopy
  12.     Clr.B    -1(A1)        ;mark the end of the offset
  13.     Move.L    A0,A3        ;data after comma
  14.  
  15.     Move.L    #WorkData,D1
  16.     Move.L    #_OffsetVal,D2
  17.     CALL    StrToLong,DOS        ;convert a decimal string into a longword
  18.     Cmp.L    #-1,D0
  19.     Beq    .BadOffset
  20.  
  21.     Move.L    _FileData(PC),A0    ;start of the data from our file to load
  22.     Move.L    _OffsetVal(PC),D0    ;how far into the do we need to go
  23.     Lea    (A0,D0.w),A4        ;move to it
  24.  
  25.     Move.B    (A3),D0
  26.     Cmp.B    #'"',D0        ;are the characters an ASCII string, instead of a sequence of hex
  27.     Bne.S    .OffsetLoop2        ;if not, go process the hex
  28.  
  29.     Move.L    A3,A0
  30.     Lea    WorkData,A1        ;copy the string elsewhere
  31.     Bsr    StripQuotes        ;removing the quotes around it as we go
  32.  
  33.     Lea    WorkData,A0
  34. .OffsetLoop    Moveq    #0,D0
  35.     Moveq    #0,D1
  36.     Move.B    (A0)+,D0        ;get a character of the string
  37.     Beq.S    .OffsetDone        ;if it's zero, then the check has worked
  38.     Move.B    (A4)+,D1        ;data file
  39.  
  40.     Tst.B    _Insensitive        ;are we caring about case sensitivity?
  41.     Beq.S    .NoInsensitive        ;if so, then skip the routines to convert to uppercase
  42.     Bsr    ChangeCase        ;convert the OFFSET character
  43.     Exg.L    D1,D0        ;swap the two characters over
  44.     Bsr    ChangeCase        ;convert the data from the file
  45.     Exg.L    D1,D0        ;swap the two characters over
  46. .NoInsensitive    Cmp.B    #'?',D0        ;is it a wildcard?
  47.     Beq.S    .OffsetLoop        ;if so, then skip the comparison
  48.     Cmp.B    D0,D1        ;compare the two characters
  49.     Beq.S    .OffsetLoop        ;if they are the same, then continue the check
  50.     Bra.S    .BadOffset        ;if they are different, then stop checking with this class
  51.  
  52. .OffsetLoop2    Moveq    #0,D0
  53.     Moveq    #0,D1
  54.     Move.B    (A3)+,D0        ;get a character of the string
  55.     Beq.S    .OffsetDone
  56.  
  57.     Cmp.B    #'.',D0        ;is a skip character
  58.     Bne.S    .NotSkip
  59.     Addq    #1,A3        ;jump over the second '.'
  60.     Addq    #1,A4        ;jump over the byte in the datafile
  61.     Bra.S    .OffsetLoop2
  62.  
  63. .NotSkip    Bsr    ChangeCase        ;the user may type the hex in upper or lower case
  64.     Move.B    D0,D1
  65.     Sub.B    #48,D1        ;drop ascii back to decimal
  66.     Cmp.B    #10,D1
  67.     Blt.S    .NotHex
  68.     Subq    #7,D1        ;drop hex back into base 10
  69. .NotHex    Lsl.W    #4,D1        ;we have the 10's column
  70.  
  71.     Move.B    (A3)+,D0        ;get the second part of the hex number
  72.     Bsr    ChangeCase
  73.     Sub.B    #48,D0        ;remove Ascii coding
  74.     Cmp.B    #10,D0
  75.     Blt.S    .NotHex2
  76.     Subq    #7,D0        ;make hex into decimal
  77.  
  78. .NotHex2    Add.B    D0,D1        ;build the final number
  79.     Move.B    (A4)+,D0        ;get the character to compare out of the data file
  80.  
  81.     Tst.B    _Insensitive        ;are we caring about case sensitivity?
  82.     Beq.S    .NoInsensitive2        ;if so, then skip the routines to convert to uppercase
  83.     Bsr    ChangeCase        ;convert the OFFSET character
  84.     Exg.L    D1,D0        ;swap the two characters over
  85.     Bsr    ChangeCase        ;convert the data from the file
  86.     Exg.L    D1,D0        ;swap the two characters over
  87. .NoInsensitive2
  88.     Cmp.L    D0,D1        ;are they the same
  89.     Beq.S    .OffsetLoop2        ;if so, check the next character
  90.     Bra.S    .BadOffset
  91. .OffsetDone
  92.  
  93.     Addq.B    #1,_Successful
  94.  
  95.     Cmp.B    #MODE_ONE,_Mode
  96.     Beq.S    LaunchAction
  97.     Bra.S    .NoOffset
  98.  
  99. .BadOffset    Cmp.B    #MODE_ALL,_Mode
  100.     Beq    CheckLoop
  101. .NoOffset
  102.